﻿<cfsilent>
	<cfscript>
		
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "学籍管理 - 在校生班级查询");
		
		passArgs = structNew();
		
		currentTab = event.getArg("TabID", "labSearch");
		
		termId = event.getArg("TermID");
		
		/*所有学生类型信息*/
		sql = "SELECT code_id, name FROM i_code_info 
			where field_id = '2' 
			AND name in(
				SELECT b.nationality FROM i_stu_class_info a 
				INNER JOIN t_student b ON b.stu_id = a.stu_id 
				INNER JOIN t_class c ON c.cls_id = a.cls_id 
				WHERE substr(c.grade,3,3) = :termId 
			)
			order by length(name), name";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_varchar" );
		
		rs_country = queryObj.execute( sql=sql ).getResult();
		
		
		/* 搜索学生档案 */
		countryName = event.getArg("name");

		rs_student = queryNew("stu_id");
		
		if ( len(countryName) ) {
			
			/*所选国家*/
			sql = "SELECT name FROM i_code_info where name = :name";
			
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="name", value=countryName, cfsqltype="cf_sql_varchar" );
			
			rs_CountryEntity = queryObj.execute( sql=sql ).getResult();
			
			sql = "SELECT b.stu_id, b.stu_name, b.stu_name_english, b.stu_sex,  c.cls_name, d.tch_name FROM i_stu_class_info a 
					INNER JOIN t_student b ON b.stu_id = a.stu_id 
					INNER JOIN t_class c ON c.cls_id = a.cls_id 
					INNER JOIN t_teacher d ON d.tch_id = c.teacher_in_charge 
					WHERE substr(c.grade,3,3) = :termId 
					AND b.nationality = :countryName 
					ORDER BY c.cls_name";
			
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="countryName", value=countryName, cfsqltype="cf_sql_varchar" );
			
			rs_student = queryObj.execute( sql=sql ).getResult();
	
						
		}

		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">学生学籍管理</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>按国家查询在校生班级
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">班级查询</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentClassByCountry')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
                              <label><b>国家</b>:</label>&nbsp;&nbsp;&nbsp;
                              <span style="position:absolute;border:1pt solid #c1c1c1;overflow:hidden;width:188px;height:19px;clip:rect(-1px 190px 190px 170px);">
                                   <select name="opt" id="opt" style="width:190px;height:20px;margin:-2px;" 
     onChange="javascript:document.getElementById('name').value=document.getElementById('opt').options[document.getElementById('opt').selectedIndex].value;">
     样-->
                                        <cfloop query="rs_country">
                                              <option <cfif countryName eq rs_country.name>selected="selected"</cfif> value="<cfoutput>#rs_country.name#</cfoutput>"><cfoutput>#rs_country.name#</cfoutput></option>
                                         </cfloop>
                                   </select>
						</span>
                              
                              <span style="position:absolute;border-top:1pt solid #c1c1c1;border-left:1pt solid #c1c1c1;border-bottom:1pt solid #c1c1c1;width:170px;height:19px;">
                              	<input type="text" name="name" id="name" value="<cfoutput>#countryName#</cfoutput>" style="width:170px;height:15px;border:0pt;">
                              </span>

                    
						<br/><br/><hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					 <cfif rs_student.recordCount>

                    
                              <cfset row = 0 />
                              <table class="UIEditable">
                                   <thead>
                                        <tr>
                                             <td width="18"></td>
                                             <td>国家</td>
                                             <td>学生学号</td>
                                             <td width="160px">英文名</td>
                                             <td width="160px">中文名</td>
                                             <td>性别</td>
                                             <td>班级</td>
                                             <td>班主任</td>
                                        </tr>
                                   </thead>
                                   <tbody>
                                        <cfloop query="rs_student">
                                        
                                           
                                             <cfset row++ />
                                             
                                             
                                             <tr class="editRows">
                                                  <td class="index"><cfoutput>#row#</cfoutput></td>
                                                  <td><cfoutput>#countryName#</cfoutput></td>
                                                  <td><cfoutput>#rs_student.stu_id#</cfoutput></td>
                                                
                                                  <td><cfoutput>#rs_student.stu_name_english#</cfoutput></td>
                                                  <td><cfoutput>#rs_student.stu_name#</cfoutput></td>
                                                  <td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
                                                  <td><cfoutput>#rs_student.cls_name#</cfoutput></td>
                                                  <td><cfoutput>#rs_student.tch_name#</cfoutput></td>
                                                      
                                             </tr>
                                        </cfloop>
                                   </tbody>
                              </table>
                              
                                   
                    
                  		</cfif>
					
				</div>
                    <cfif len(countryName) AND rs_CountryEntity.recordCount eq 0>
                    	 <div class="systemNotice">
                             <p>没有这个国家，名字输入错误</p>
                        	</div>
                    </cfif>
                    
                     <cfif len(countryName) AND rs_student.recordCount eq 0 and rs_CountryEntity.recordCount neq 0>
                    	 <div class="systemNotice">
                             <p>输入的国家在本学期没有学生班级数据 (你可以在下拉框中选择正确的国家)</p>
                        	</div>
                    </cfif>
                 
				
			</div>
		</li>
	</ul>
</div>